<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Elasticsearch 多语言支持完全指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
        }
        .serif-font {
            font-family: 'Noto Serif SC', serif;
        }
        .gradient-text {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-4px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 12px;
            overflow-x: auto;
        }
        .code-block code {
            font-family: 'Consolas', 'Monaco', monospace;
        }
        .section-divider {
            height: 1px;
            background: linear-gradient(to right, transparent, #e5e7eb, transparent);
        }
        .feature-icon {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            margin-top: -0.2rem;
            color: #667eea;
        }
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        .animate-fadeInUp {
            animation: fadeInUp 0.6s ease-out;
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto animate-fadeInUp">
            <div class="text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 serif-font">
                    Elasticsearch 多语言支持
                </h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90">
                    构建全球化搜索引擎的完整解决方案
                </p>
                <div class="flex justify-center space-x-6 text-lg">
                    <div class="flex items-center">
                        <i class="fas fa-globe mr-2"></i>
                        <span>全球化支持</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-language mr-2"></i>
                        <span>智能分词</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-search mr-2"></i>
                        <span>精准搜索</span>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Introduction -->
    <section class="py-16 px-6">
        <div class="max-w-4xl mx-auto">
            <div class="bg-white rounded-2xl shadow-lg p-8 md:p-12 card-hover">
                <p class="text-lg leading-relaxed text-gray-700">
                    <span class="drop-cap serif-font">在</span>Elasticsearch（ES）中实现多语言支持是提升搜索引擎用户体验和准确性的关键。随着全球化的推进，应用面临着需要处理多种语言的挑战。本指南将深入探讨如何在 Elasticsearch 中构建一个强大的多语言搜索系统，让您的应用能够无缝支持全球用户。
                </p>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <section class="py-12 px-6">
        <div class="max-w-6xl mx-auto">
            
            <!-- Section 1: 分词器 -->
            <div class="mb-16">
                <div class="flex items-center mb-8">
                    <div class="bg-purple-100 rounded-full p-4 mr-4">
                        <i class="fas fa-cut text-3xl feature-icon"></i>
                    </div>
                    <h2 class="text-3xl font-bold text-gray-800">1. 使用合适的分词器</h2>
                </div>
                
                <div class="bg-white rounded-2xl shadow-lg p-8 mb-8">
                    <p class="text-lg text-gray-700 mb-6">
                        分词器（Analyzer）是处理文本数据的核心工具。针对不同语言，选择合适的分词器是实现多语言支持的第一步。
                    </p>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div class="bg-gradient-to-br from-purple-50 to-pink-50 rounded-xl p-6 card-hover">
                            <h3 class="text-xl font-semibold mb-4 text-gray-800">
                                <i class="fas fa-box mr-2 text-purple-600"></i>自带分词器
                            </h3>
                            <ul class="space-y-3">
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                                    <div>
                                        <strong>Standard Analyzer</strong>
                                        <p class="text-gray-600">适用于英语等拉丁字母语言</p>
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                                    <div>
                                        <strong>IK Analyzer</strong>
                                        <p class="text-gray-600">适用于中文，能够处理词语的切分</p>
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                                    <div>
                                        <strong>NGram Analyzer</strong>
                                        <p class="text-gray-600">适用于需要模糊匹配的情况</p>
                                    </div>
                                </li>
                            </ul>
                        </div>
                        
                        <div class="bg-gradient-to-br from-blue-50 to-indigo-50 rounded-xl p-6 card-hover">
                            <h3 class="text-xl font-semibold mb-4 text-gray-800">
                                <i class="fas fa-cog mr-2 text-blue-600"></i>自定义分词器
                            </h3>
                            <p class="text-gray-700">
                                对于不常见的语言或特殊需求，可以通过自定义分词器来满足特定的文本处理需求。这为处理特殊语言或行业术语提供了灵活性。
                            </p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="section-divider mb-16"></div>

            <!-- Section 2: 索引设计 -->
            <div class="mb-16">
                <div class="flex items-center mb-8">
                    <div class="bg-blue-100 rounded-full p-4 mr-4">
                        <i class="fas fa-database text-3xl feature-icon"></i>
                    </div>
                    <h2 class="text-3xl font-bold text-gray-800">2. 多语言索引设计</h2>
                </div>
                
                <div class="bg-white rounded-2xl shadow-lg p-8">
                    <p class="text-lg text-gray-700 mb-8">
                        为了支持多种语言的文档，索引的设计需要灵活。合理的索引结构是实现高效多语言搜索的基础。
                    </p>
                    
                    <div class="mb-8">
                        <h3 class="text-xl font-semibold mb-4 text-gray-800">
                            <i class="fas fa-layer-group mr-2 text-blue-600"></i>多字段映射
                        </h3>
                        <p class="text-gray-700 mb-4">在索引映射中，可以为每种语言创建单独的字段：</p>
                        <div class="code-block p-6">
                            <pre><code>{
  "mappings": {
    "properties": {
      "title_en": { "type": "text", "analyzer": "standard" },
      "title_zh": { "type": "text", "analyzer": "ik_max_word" },
      "title_es": { "type": "text", "analyzer": "spanish" }
    }
  }
}</code></pre>
                        </div>
                    </div>
                    
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-gray-800">
                            <i class="fas fa-tags mr-2 text-blue-600"></i>使用多语言字段
                        </h3>
                        <p class="text-gray-700">
                            使用统一的字段名，结合语言标识符（如 <code class="bg-gray-100 px-2 py-1 rounded">title:en</code>、<code class="bg-gray-100 px-2 py-1 rounded">title:zh</code>），实现多语言支持。这可以让用户在查询时指定所需的语言。
                        </p>
                    </div>
                </div>
            </div>

            <div class="section-divider mb-16"></div>

            <!-- Section 3: 查询处理 -->
            <div class="mb-16">
                <div class="flex items-center mb-8">
                    <div class="bg-green-100 rounded-full p-4 mr-4">
                        <i class="fas fa-search text-3xl feature-icon"></i>
                    </div>
                    <h2 class="text-3xl font-bold text-gray-800">3. 查询时的语言处理</h2>
                </div>
                
                <div class="bg-white rounded-2xl shadow-lg p-8">
                    <div class="grid md:grid-cols-2 gap-8">
                        <div>
                            <h3 class="text-xl font-semibold mb-4 text-gray-800">
                                <i class="fas fa-bolt mr-2 text-green-600"></i>动态分词
                            </h3>
                            <p class="text-gray-700">
                                根据用户选择的语言，动态选择相应的分词器进行查询。通过传递语言参数，可以根据需要选择合适的分析器。
                            </p>
                        </div>
                        
                        <div>
                            <h3 class="text-xl font-semibold mb-4 text-gray-800">
                                <i class="fas fa-globe-asia mr-2 text-green-600"></i>多语言查询
                            </h3>
                            <p class="text-gray-700 mb-4">
                                在构建查询时，利用 <code class="bg-gray-100 px-2 py-1 rounded">bool</code> 查询结合多个 <code class="bg-gray-100 px-2 py-1 rounded">match</code> 子句：
                            </p>
                        </div>
                    </div>
                    
                    <div class="mt-6">
                        <div class="code-block p-6">
                            <pre><code>{
  "query": {
    "bool": {
      "should": [
        { "match": { "title_en": "search term" } },
        { "match": { "title_zh": "搜索词" } },
        { "match": { "title_es": "término de búsqueda" } }
      ]
    }
  }
}</code></pre>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Visualization -->
            <div class="mb-16">
                <div class="bg-gradient-to-br from-purple-50 to-pink-50 rounded-2xl p-8">
                    <h3 class="text-2xl font-bold text-center mb-8 text-gray-800">多语言搜索架构图</h3>
                    <div class="mermaid">
                        graph TD
                            A[用户查询] --> B{语言检测}
                            B --> C[英文分词器]
                            B --> D[中文分词器]
                            B --> E[西班牙语分词器]
                            C --> F[索引查询]
                            D --> F
                            E --> F
                            F --> G[结果聚合]
                            G --> H[返回结果]
                            
                            style A fill:#667eea,stroke:#fff,color:#fff
                            style H fill:#764ba2,stroke:#fff,color:#fff
                            style B fill:#f3f4f6,stroke:#667eea